package juc.day01;

import java.util.concurrent.*;

/**
 * @author wang hao
 * @date 2023-02-28 21:27
 */
public class Demo06 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ExecutorService threadPool = Executors.newFixedThreadPool(1);
        threadPool.execute(() -> {
            System.out.println("hello world");
        });

        FutureTask<String> futureTask = new FutureTask<String>(() -> {
            return "1";
        });

        threadPool.submit(futureTask);
        String s = futureTask.get();
        System.out.println("结果是:" + s);

        threadPool.shutdown();
        threadPool.awaitTermination(1, TimeUnit.MINUTES);
    }
}
